#!/usr/bin/env python
# -*- coding: utf-8 -*-

import wx
import wx.lib.agw.aui as aui
from core.utils.singleton import singleton


PANE_LEFTPANEL       = aui.AuiPaneInfo().CloseButton(True).MaximizeButton(True).Left().Position(1).BestSize((200, 100)).MinimizeButton(True)
PANE_RIGHTPANEL      = aui.AuiPaneInfo().CloseButton(True).MaximizeButton(True).Right().Position(1).BestSize((200, 100)).MinimizeButton(True)
PANE_BUTTOM          = aui.AuiPaneInfo().CloseButton(True).MaximizeButton(True).Bottom().Position(1).BestSize((200, 100)).MinimizeButton(True)
PANE_MASTER          = aui.AuiPaneInfo().CenterPane()
PANE_CENTER          = "main"

@singleton
class MainFrame(wx.Frame):
    def __init__(self):
        style=wx.DEFAULT_FRAME_STYLE | wx.SUNKEN_BORDER | wx.CLIP_CHILDREN
        self._frame=wx.Frame.__init__(self,None, 1, 'Druid', size=(1024,768),style=style)
        self._auiManager=aui.AuiManager(self)
        #self.Bind(wx.EVT_CLOSE,self.close)

    def update(self):
        self._auiManager.Update()

    def addPane(self, wxObject, auiInfo=None):
        if not auiInfo:
            auiInfo=PANE_LEFTPANEL
        if auiInfo==PANE_CENTER:
            self.addPage(wxObject)
            return

        if(hasattr(wxObject,'name')):
            auiInfo.Name(wxObject.name)
            auiInfo.Caption(wxObject.name)
        self._auiManager.AddPane(wxObject, auiInfo)
        self.update()

    def start(self):
        pass
    
    def close(self):
        pass